﻿using Sl.Duplex;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ChholConfig.UserSerial {
	public partial class NodesSerialportForm : Form {
		private NodesSerialportForm() {
			InitializeComponent();
		}
		public NodesSerialportForm(IDuplex port) {
			InitializeComponent();
			mainStm.Port = port;
			mainStm.Port.openPort();
			this.Text = mainStm.Port.Name;
			
		}
		protected override void OnClosed(EventArgs e) {
			base.OnClosed(e);
			mainStm.Port.Dispose();
		}
		public Action<string> dUpdateSpeed;

		private void SpeedUpdateTimer_Tick(object sender, EventArgs e) {
			mainStm.CheckSpeedLoop();
			SpeedLAB.Text = $"收/发字节数={mainStm.Send_count}B/{mainStm.Recv_count}B";
			dUpdateSpeed(SpeedLAB.Text);
			//	$"收/发速率={mainStm.Send_speed:f2}Bps/{mainStm.Recv_speed:f2}Bps";
		}
	}
	

}
